var path = require("path");
var webpack = require("webpack");
const os = require("os");
const baseConfig = require("./webpack.base.config");
const merge = require("webpack-merge");
///获取本机ip///
function getIPAdress() {
    var interfaces = os.networkInterfaces();
    for (var devName in interfaces) {
        var iface = interfaces[devName];
        for (var i = 0; i < iface.length; i++) {
            var alias = iface[i];
            if (
                alias.family === "IPv4" &&
                alias.address !== "127.0.0.1" &&
                !alias.internal
            ) {
                return alias.address;
            }
        }
    }
}
const myHost = getIPAdress();

console.log("\x1B[36m%s\x1B[0m", "http://" + myHost + ":8080");

module.exports = merge.merge(baseConfig, {
    entry: "./src/main.js",
    output: {
        path: path.resolve(__dirname, "./dist"),
        publicPath: "/dist/",
        filename: "build.js",
    },
    devServer: {
        historyApiFallback: true,
        noInfo: true,
        overlay: true,
        host: myHost,
    },
});
console.log("===path", path.resolve("./src/dev/components"));
module.exports.devtool = "#source-map";
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.DefinePlugin({
        "process.env": {
            NODE_ENV: '"development"',
        },
    }),
    new webpack.optimize.UglifyJsPlugin({
        sourceMap: true,
        compress: {
            warnings: false,
        },
    }),
    new webpack.LoaderOptionsPlugin({
        minimize: true,
    }),
]);